'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
/* eslint-disable */
exports.default = {
  bind: function bind(el, binding) {
    var target = el;
    if (el.getAttribute('data-scrollTarget')) {
      target = el.querySelector(el.getAttribute('data-scrollTarget'));
    }
    target.addEventListener('scroll', function (e) {
      var busy = el.getAttribute('data-infiniteScrollDisabled') ? false : true;
      var distance = el.getAttribute('data-infiniteScrollDistance') ? Number.parseInt(el.getAttribute('data-infiniteScrollDistance'), 10) : 100;
      if (!busy && e.target.scrollHeight - (e.target.scrollTop + e.target.clientHeight) < distance) {
        el.setAttribute('data-infiniteScrollDisabled', true);
        binding.value(e);
      }
    });
  }
};